<?php
declare (strict_types = 1);

namespace app\service;
use think\Service;
use app\common\Eldata;

class ReWriteDataService  extends \think\Service
{

    /**
     * 注册服务
     *
     * @return mixed
     */
    public function register()
    {
        $this->app->bind('eldata_system',Eldata::class);
    }


    /**
     * 执行服务
     *
     * @return mixed
     */
    public function boot()
    {
        $indexName= 'view_datas';
        $indexTypeDataStruct=[
            'view_data' => [
                '_source' => [
                    'enabled' => true,
                ],
                'properties' => [
                    'view_type' => [
                        'type' => 'integer',
                        'analyzer' => 'standard'
                    ],
                    'view_search_url' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_copy_data' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_cur_url' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_platform' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_endpoint' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_keywords' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed',
                    ],
                    'view_screen' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed',
                    ],
                    'view_lat' => [
                        'type' => 'double',
                        'analyzer' => 'standard',
                    ],
                    'view_lon' => [
                        'type' => 'double',
                        'analyzer' => 'standard'
                    ],
                    'view_province' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_city' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_nation' => [
                        'type' => 'string',
                        'analyzer' => 'no_analyzed'
                    ],
                    'view_time' => [
                        'type' => 'date',
                        'format' => 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis'
                    ]
                ]
            ]
        ];
        Eldata::setIndexNameStruct($indexName, $indexTypeDataStruct);
    }
}
